﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Frame.Lib.Core.User;
using Frame.Lib.Common;
using Frame.Lib.Utilities;

namespace Frame.Web.Admin.User
{
    public partial class ModifyPwd : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            UserBO user = new UserBO();
            string strOld = txtOldPwd.Text.Trim();
            string strNew = txtNewPwd.Text.Trim();
            string strConfirm = txtConfirmPwd.Text.Trim();

            int userID = AppSession.UserID;
            string strLoginName = AppSession.LoginName;
            LoginResult result = user.CheckLogin(strLoginName, strOld);
            if (result == LoginResult.Success)
            {
                UserInfo info = user.GetInfo(userID);
                info.Password = strNew;
                user.ModifyPwd(info);

                JSUtil.Alert("修改成功！");
            }
            else
            {
                JSUtil.Alert("旧密码错误！");
            }
        }
    }
}